home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: jlilley@ix.netcom.com (John Lilley)
- Newsgroups: comp.lang.c++
- Subject: Re: Explicit copy constructor calls illegal?
- Date: 15 Mar 1996 02:31:11 GMT
- Organization: Netcom
- Distribution: world
- Message-ID: <4iakpf$3s0@ixnews3.ix.netcom.com>
- References: <4i9tp8$fgt@reznor.larc.nasa.gov>
- NNTP-Posting-Host: den-co10-19.ix.netcom.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-NETCOM-Date: Thu Mar 14 6:31:11 PM PST 1996
- X-Newsreader: WinVN 0.99.7
-
- >Why can I not make an explicit call to a copy constructor from a class
- >member function? To define my terminology, the copy constructor is the
- >function:
- > MyClass(const MyClass&)
-
- Calling any constructor explicitly is not a good idea except in
- rare cases. If what you are trying to do is centralize basic
- copying, then you can define and call operator=():
-
- MyClass& operator=(const MyClass& rhs)
- {
- if (this != &rhs)
- {
- ... copy members here...
- }
- }
-
- john lilley
-
-